﻿/********************************************************************************
 * Developed by Phil Tyler (http://www.laidbackcoder.co.uk)
 * 
 * Cryptosolic is Licensed under the GNU Lesser General Public License (LGPL)
 * http://cryptosolic.codeplex.com/license
 * *****************************************************************************/
using System;
using NUnit.Framework;
using Cryptosolic.Utilities;
using Cryptosolic.Utilities.Exceptions;


namespace Cryptosolic.Utilities.Tests
{
	[TestFixture]
	public class HexToolsTests
	{
		[Test]
		public void HexTools_CheckHex_ThrowsExceptionWhenNumberOfHexCharsAreOdd()
		{
			Assert.Throws<InvalidHexException>(() => 
            {        
	            HexTools.CheckHex("AAB");
            });
		}
		
		[Test]
		public void HexTools_CheckHex_DoesNotThrowsExceptionWhenNumberOfHexCharsAreEven()
		{
			Assert.DoesNotThrow(() => 
            {        
	            HexTools.CheckHex("AABB");
            });
		}
		
		[Test]
		public void HexTools_CheckHex_ThrowsExceptionWhenHexContainsInvalidChars()
		{
			Assert.Throws<InvalidHexException>(() => 
            {        
			    //'G' is not Valid in Hex                                                               	
	            HexTools.CheckHex("AABG");
            });
		}
		
		[Test]
		public void HexTools_CheckHex_DoesNotThrowsExceptionWhenAllHexCharsAreValid()
		{
			Assert.DoesNotThrow(() => 
            {   
				//Testing with Every Valid Char			                    	
	           HexTools.CheckHex("0123456789ABCDEF");
            });
		}
	}
}
